<?php
/**
 * Search.php
 * Created by PhpStorm.
 * User: 江小波
 * Date: 2019/06/14
 * Time: 11:33
 */
namespace app\api\open\payment;

use app\api\open\Base;
use app\api\model\PaymentModel;
use app\common\Singleton;

class Search extends Base
{
    protected $where = [];

    public function __construct($param = [])
    {
        parent::__construct($param);

		// 是否启用（0否，1是）
		if(isset($this->params['is_enable']) && $this->params['is_enable']!='')
		{
			$this->where['is_enable'] = $this->params['is_enable'];
		}
		// 顺序
		if(isset($this->params['sort']) && $this->params['sort']!='')
		{
			$this->where['sort'] = $this->params['sort'];
		}
		// 名称
		if(isset($this->params['name']) && $this->params['name']!='')
		{
			$this->where['name'] = $this->params['name'];
		}
		// 唯一标记
		if(isset($this->params['payment']) && $this->params['payment']!='')
		{
			$this->where['payment'] = $this->params['payment'];
		}
		// 描述
		if(isset($this->params['desc']) && $this->params['desc']!='')
		{
			$this->where['desc'] = $this->params['desc'];
		}
		// 适用终端 php一维数组json字符串存储（pc, wap, app, alipay, weixin, baidu）
		if(isset($this->params['apply_terminal']) && $this->params['apply_terminal']!='')
		{
			$this->where['apply_terminal'] = $this->params['apply_terminal'];
		}
		// 配置数据
		if(isset($this->params['config']) && $this->params['config']!='')
		{
			$this->where['config'] = $this->params['config'];
		}
    }
    
    /**
     * @param array $param
     * @return array|false|null|\PDOStatement|string|\think\Model
     * @throws \Exception
     */
    public function index($param=[])
    {
        // 获取列表
        return PaymentModel::getInstance()->getList($this->where,[
            'field'=> '*'
        ]);
    }
}